import { ArrayMinSize, IsInt, IsNotEmpty, Min, Max, validate } from 'class-validator'
import { Type, plainToClass } from 'class-transformer'
import { IMovie } from '../public/interface'
import { CommonClass } from '../public/classes/common'

export class Movie extends CommonClass {
  @IsNotEmpty({ message: '电影名称不能为空' })
  @Type(() => String)
  public name: string

  @IsNotEmpty({ message: '电影类型不能为空' })
  @ArrayMinSize(1, { message: '电影类型不能为空' })
  @Type(() => String)
  public types: string[]

  @IsNotEmpty({ message: '上映区域不能为空' })
  @ArrayMinSize(1, { message: '上映区域不能为空' })
  @Type(() => String)
  public areas: string[]

  @IsNotEmpty({ message: '电影时长不能为空' })
  @IsInt({ message: '时长必须为整数' })
  @Min(1, { message: '电影时长必须大于1分钟' })
  @Max(99999, { message: '电影时长过长' })
  @Type(() => Number)
  public timeLong: number

  @Type(() => Boolean)
  @IsNotEmpty({ message: '是否正在热映不能为空' })
  public isHot: boolean = false

  @Type(() => Boolean)
  @IsNotEmpty({ message: '是否即将上映不能为空' })
  public isComing: boolean = false

  @Type(() => Boolean)
  @IsNotEmpty({ message: '是否经典影片不能为空' })
  public isClassic: boolean = false

  public description?: string

  public poster?: string
}